<template>
  <j-modal
    :title="$t('详情')"
    :width="width"
    :visible="visible"
    switchFullscreen
    :okButtonProps="{ class: { 'jee-hidden': disableSubmit } }"
    @cancel="handleCancel"
  >
    <template slot="footer">
      <a-button type="primary" @click="handleCancel">{{ $t('关闭') }}</a-button>
    </template>
    <div>
      <a-row style="padding: 20px 0">
        <a-col :span="22" :offset="1">
          <a-table :columns="columns" :dataSource="dataSource" :pagination="false" bordered> </a-table>
        </a-col>
      </a-row>
    </div>
  </j-modal>
</template>

<script>
import { getAction } from '@/api/manage'
export default {
  name: 'ShareDetailModal',
  components: {},
  data() {
    return {
      width: 800,
      visible: false,
      disableSubmit: false,
      model: {},
      columns: [],
      dataSource: [],
    }
  },
  methods: {
    show(record) {
      this.columns = [
        {
          title: this.$t('业务'),
          align: 'center',
          dataIndex: 'comment',
        },
      ]
      if (localStorage.getItem('operateCoin') == 1) {
        this.columns.splice(this.columns.length, 0, {
          title: this.$t('代币'),
          align: 'center',
          dataIndex: 'coin',
          customRender: function (text, record) {
            return (record.realCoinValue + record.presentCoinValue).toFixed(2)
          },
          customCell: function () {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
        })
      }
      if (localStorage.getItem('operateLottery') == 1) {
        this.columns.splice(this.columns.length, 0, {
          title: this.$t('彩票'),
          align: 'center',
          dataIndex: 'lotteryValue',
          customRender: function (text) {
            return text.toFixed(0)
          },
          customCell: function () {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
        })
      }
      if (localStorage.getItem('operateCredit') == 1) {
        this.columns.splice(this.columns.length, 0, {
          title: this.$t('积分'),
          align: 'center',
          dataIndex: 'integralValue',
          customRender: function (text) {
            return text.toFixed(0)
          },
          customCell: function () {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
        })
      }
      if (localStorage.getItem('operateALottery') == 1) {
        this.columns.splice(this.columns.length, 0, {
          title: this.$t('A票'),
          align: 'center',
          dataIndex: 'alotteryValue',
          customRender: function (text) {
            return text.toFixed(0)
          },
          customCell: function () {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
        })
      }
      if (localStorage.getItem('operateACoin') == 1) {
        this.columns.splice(this.columns.length, 0, {
          title: this.$t('A币'),
          align: 'center',
          dataIndex: 'pointsValue',
          customRender: function (text) {
            return text.toFixed(0)
          },
          customCell: function () {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
        })
      }
      this.dataSource = []
      this.visible = true
      this.model = Object.assign({}, record)
      this.model.notCheckOut = 0
      getAction('/checkout/notCheckOut/notCheckOutShare', this.model).then((res) => {
        if (res.success) {
          this.dataSource = res.result
        }
      })
    },
    close() {
      this.visible = false
    },
    handleCancel() {
      this.close()
    },
  },
}
</script>